home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9932 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.sources.wanted,comp.lang.c,comp.unix.programmer
  4. Subject: Re: Seek unix2dos.c OR help with tr
  5. Date: 14 Mar 1996 07:22:12 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4i9dj4INN7kl@keats.ugrad.cs.ubc.ca>
  8. References: <4i0946$7io@nuke.csu.net> <danpop.826545577@rscernix>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <danpop.826545577@rscernix>, Dan Pop <danpop@mail.cern.ch> wrote:
  12. >In <4i0946$7io@nuke.csu.net> mclean@futon.SFSU.EDU (Emmett Mclean) writes:
  13. >
  14. >>Does anyone have the source to a program
  15. >>converting a unix file into dos format?
  16. >>That is, each decimal 10 char is replaced
  17. >>with a series of a 10 and 13.
  18. >
  19. >Thinking and programming in terms of magic numbers is a bad idea.
  20. >Someone who is less familiar with the ASCII character set won't be able 
  21. >to make any sense out of your code.  A program which will replace '\n'
  22. >by the '\r' '\n' sequence will be considerably more readable, even if
  23. >portability is not a concern (both DOS and Unix use the ASCII character
  24. >set).
  25.  
  26. When I know that I'm specifically dealing with ASCII control chars, I have a
  27. macro like:
  28.  
  29. #define CTRL(C) ((C)-64)
  30.  
  31. which I then use with capital letters:
  32.  
  33.     switch(char) {
  34.     case CTRL('M'):
  35.         .
  36.         .
  37.         .
  38.     }
  39. -- 
  40.  
  41.